package com.example.oasystem.dao.process;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.oasystem.entity.process.*;
import com.example.oasystem.entity.type.AoaTypeList;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AoaProcessListDaoOfChen extends BaseMapper<AoaProcessListOfChen> {
    //根据审核人名字查自己所管理的审核
    List<ProcessDTOOfChen> getProcess(@Param("userName") String userName,
                                @Param("baseKey") String baseKey);

    List<ProcessDTOOfChen> getStatusId(int pid);
    //出差
    AoaProcessListOfChen findeve(@Param("id") int id);
    @Select("SELECT * FROM aoa_type_list t  JOIN aoa_process_list p ON p.deeply_id=t.type_id WHERE type_model='aoa_process_list' AND  p.process_id=#{id}  ")
   //紧急
    AoaTypeList GetHary(@Param("id") int id);
    //请假
    AoaProcessListOfChen getHo(@Param("id") int id);
    //出差费用
    AoaProcessListOfChen getMon(@Param("id") int id);
    //离职申请
    AoaProcessListOfChen getLizhi(@Param("id") int id);
    //转正
    AoaProcessListOfChen getZhuanzheng(@Param("id") int id);
    //加班申请
    AoaProcessListOfChen getJiaban(@Param("id") int id);
    //费用报销
    baoxiaoDTO getFeiyongBaoxiao(@Param("id") int id);
    @Select("select *from aoa_attachment_list where attachment_id =${id}")
    AoaAttachmentList getTupian(@Param("id") int id);

    @Select("select * from aoa_detailsburse a LEFT JOIN aoa_bursement b on a.bursment_id = b.bursement_id where b.pro_id = #{proId}")
    List<details> getDetail(int proId);

    @Select("select\n" +
            "\tt.traffic_id,t.depart_name,t.depart_time,t.reach_name,t.seat_type,t.traffic_money,t.traffic_name,t.evection_id,t.user_name tuid,\n" +
            "\tu.user_name\n" +
            "\tfrom aoa_traffic t,aoa_user u\n" +
            "\twhere t.user_name = u.user_id\n" +
            "\tand evection_id = ${proId}")
    List<tralist> getTralist(int proId);

    @Select("\tSELECT*,s.user_name suid,u.user_name stayname from aoa_process_list l \n" +
            "LEFT JOIN aoa_evectionmoney e\n" +
            "ON e.pro_id=l.process_id\n" +
            "left join aoa_stay s\n" +
            "on s.evemoney_id=e.evectionmoney_id\n" +
            "left join aoa_user u\n" +
            "on u.user_id=l.process_user_id\n" +
            "WHERE l.process_id=${proId}")
    List<AoaStay> getStay(int proId);
    //根据proid和typeName删除不同内容的表
    @Delete("delete from ${type} where pro_id = #{proId}")
    Integer DeleteByType(@Param("proId") int proId, @Param("type") String type);
    //删除reviewed表中的数据
    @Delete("delete from aoa_reviewed where user_id = #{userId} and pro_id = #{proId}")
    Integer DeleteProcess(@Param("userId") int userId, @Param("proId") int proId);
    //根据proID获取审核人的名字
    @Select("select shenuser from aoa_process_list where process_id = #{proId}")
    String getShenUsers(int proId);
    //当审核的人不止一个
    @Update("update aoa_process_list set shenuser  =#{shenuser} where process_id = #{proId}")
    Integer UpdateByName(@Param("proId") int proId, String shenuser);

    //审核的人只有一个
    @Delete("delete from aoa_process_list where process_id = #{proId}")
    Integer DeleteByname(int proId);



}